// Created by WXX on 2021/9/18 10:48
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

class Solution {
public:
    int findComplement(int num) {
        if (!num) return 1;
        int cnt = 0;
        for (int i = num; i; i >>= 1) cnt++;
        return ~num & ((1ll << cnt) - 1);
    }
};

int main() {

    cout << Solution().findComplement(5) << endl;  // 2

    return 0;
}
